namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0033 : DbMigration
    {
        public override void Up()
        {
            //RenameTable(name: "dbo.FimPayRequestDtl", newName: "fim_money_request_dtls");
            //RenameTable(name: "dbo.FimPayRequest", newName: "fim_money_requests");
            //RenameTable(name: "dbo.FimCheque", newName: "fim_cheques");
            //DropForeignKey("dbo.FimPay", "PayEventId", "dbo.FimMasLookUp");
            //DropForeignKey("dbo.FimPay", "PayMethodId", "dbo.FimMasLookUp");
            //DropIndex("dbo.FimPay", new[] { "PayEventId" });
            //DropIndex("dbo.FimPay", new[] { "PayMethodId" });
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "PayReqDtlId", newName: "money_req_dtls_seq");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "PayReqId", newName: "money_req_seq");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "Name", newName: "money_req_dtls_name");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "ProjOperExpId", newName: "bgm_proj_oper_exp_seq");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "JobSiteId", newName: "job_site_seq");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "PercentVat", newName: "percent_vat");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "PercentTax", newName: "percent_tax");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "AmountVat", newName: "amount_vat");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "AmountTax", newName: "amount_tax");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "NetAmount", newName: "bath_amount");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "RecordStatus", newName: "record_status");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "CreatedBy", newName: "created_by");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "CreatedWhen", newName: "created_when");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "UpdatedBy", newName: "updated_by");
            //RenameColumn(table: "dbo.fim_money_request_dtls", name: "UpdatedWhen", newName: "updated_when");
            //RenameColumn(table: "dbo.fim_money_requests", name: "PayReqId", newName: "money_req_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "BgSourceId", newName: "bgm_source_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "BgYear", newName: "bgm_year");
            //RenameColumn(table: "dbo.fim_money_requests", name: "WorkAreaId", newName: "work_area_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "ExpGrpId", newName: "bgm_exp_grp_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "PayEventId", newName: "event_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "PayReqDate", newName: "money_req_date");
            //RenameColumn(table: "dbo.fim_money_requests", name: "UseAdvance", newName: "use_advance");
            //RenameColumn(table: "dbo.fim_money_requests", name: "AdvanceBgSourceId", newName: "advance_bgm_source_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "Code", newName: "ref_no");
            //RenameColumn(table: "dbo.fim_money_requests", name: "DoccumentNo", newName: "doc_ref_no");
            //RenameColumn(table: "dbo.fim_money_requests", name: "Name", newName: "money_req_name");
            //RenameColumn(table: "dbo.fim_money_requests", name: "ProjOperId", newName: "bgm_proj_oper_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "EmpId", newName: "emp_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "JobSiteId", newName: "job_site_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "ContactId", newName: "contact_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "DnId", newName: "icm_dn_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "BorrowNo", newName: "borrow_no");
            //RenameColumn(table: "dbo.fim_money_requests", name: "BorrowTypeId", newName: "borrow_type_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "BorrowStartDate", newName: "borrow_start_date");
            //RenameColumn(table: "dbo.fim_money_requests", name: "BorrowEndDate", newName: "borrow_end_date");
            //RenameColumn(table: "dbo.fim_money_requests", name: "BorrowReturnDate", newName: "borrow_return_date");
            //RenameColumn(table: "dbo.fim_money_requests", name: "CreditCardNo", newName: "credit_card_no");
            //RenameColumn(table: "dbo.fim_money_requests", name: "DebtorEmpId", newName: "debtor_emp_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "DebtorContactId", newName: "debtor_contact_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "TranGrpId", newName: "tran_grp_seq");
            //RenameColumn(table: "dbo.fim_money_requests", name: "RecordStatus", newName: "record_status");
            //RenameColumn(table: "dbo.fim_money_requests", name: "CreatedBy", newName: "created_by");
            //RenameColumn(table: "dbo.fim_money_requests", name: "CreatedWhen", newName: "created_when");
            //RenameColumn(table: "dbo.fim_money_requests", name: "UpdatedBy", newName: "updated_by");
            //RenameColumn(table: "dbo.fim_money_requests", name: "UpdatedWhen", newName: "updated_when");
            //RenameColumn(table: "dbo.fim_cheques", name: "ChequeId", newName: "cheque_seq");
            //RenameColumn(table: "dbo.fim_cheques", name: "ChequeBookId", newName: "cheque_book_seq");
            //RenameColumn(table: "dbo.fim_cheques", name: "ChequeNo", newName: "cheque_no");
            //RenameColumn(table: "dbo.fim_cheques", name: "PrintDate", newName: "print_date");
            //RenameColumn(table: "dbo.fim_cheques", name: "PayDate", newName: "pay_date");
            //RenameColumn(table: "dbo.fim_cheques", name: "ChequeStatus", newName: "cheque_status");
            //RenameColumn(table: "dbo.fim_cheques", name: "RecordStatus", newName: "record_status");
            //RenameColumn(table: "dbo.fim_cheques", name: "CreatedBy", newName: "created_by");
            //RenameColumn(table: "dbo.fim_cheques", name: "CreatedWhen", newName: "created_when");
            //RenameColumn(table: "dbo.fim_cheques", name: "UpdatedBy", newName: "updated_by");
            //RenameColumn(table: "dbo.fim_cheques", name: "UpdatedWhen", newName: "updated_when");
            //AddColumn("dbo.fim_money_requests", "bidder_col_Id", c => c.Int());
            //AddColumn("dbo.fim_cheques", "bank_acc_seq", c => c.Int());
            //AddColumn("dbo.fim_cheques", "cheque_date", c => c.DateTime());
            //AddColumn("dbo.fim_cheques", "actual_pay_date", c => c.DateTime());
            //AlterColumn("dbo.fim_money_request_dtls", "amount", c => c.Decimal(precision: 18, scale: 2));
            //AlterColumn("dbo.fim_money_requests", "allow", c => c.String());
            //AlterColumn("dbo.fim_money_requests", "remarks", c => c.String());
            //AlterColumn("dbo.fim_cheques", "receiver", c => c.String());
            //AlterColumn("dbo.fim_cheques", "remarks", c => c.String());
            //AddForeignKey("dbo.fim_money_requests", "bidder_col_Id", "dbo.IcmBidderCollateral", "BidderColId");
            //AddForeignKey("dbo.fim_cheques", "bank_acc_seq", "dbo.FimMasBankAccount", "BankAccId");
            //CreateIndex("dbo.fim_money_requests", "bidder_col_Id");
            //CreateIndex("dbo.fim_cheques", "bank_acc_seq");
        }
        
        public override void Down()
        {
            DropIndex("dbo.fim_cheques", new[] { "bank_acc_seq" });
            DropIndex("dbo.fim_money_requests", new[] { "bidder_col_Id" });
            DropForeignKey("dbo.fim_cheques", "bank_acc_seq", "dbo.FimMasBankAccount");
            DropForeignKey("dbo.fim_money_requests", "bidder_col_Id", "dbo.IcmBidderCollateral");
            AlterColumn("dbo.fim_cheques", "Remarks", c => c.String());
            AlterColumn("dbo.fim_cheques", "Receiver", c => c.String());
            AlterColumn("dbo.fim_money_requests", "Remarks", c => c.String());
            AlterColumn("dbo.fim_money_requests", "Allow", c => c.String());
            AlterColumn("dbo.fim_money_request_dtls", "Amount", c => c.Decimal(precision: 18, scale: 2));
            DropColumn("dbo.fim_cheques", "actual_pay_date");
            DropColumn("dbo.fim_cheques", "cheque_date");
            DropColumn("dbo.fim_cheques", "bank_acc_seq");
            DropColumn("dbo.fim_money_requests", "bidder_col_Id");
            RenameColumn(table: "dbo.fim_cheques", name: "updated_when", newName: "UpdatedWhen");
            RenameColumn(table: "dbo.fim_cheques", name: "updated_by", newName: "UpdatedBy");
            RenameColumn(table: "dbo.fim_cheques", name: "created_when", newName: "CreatedWhen");
            RenameColumn(table: "dbo.fim_cheques", name: "created_by", newName: "CreatedBy");
            RenameColumn(table: "dbo.fim_cheques", name: "record_status", newName: "RecordStatus");
            RenameColumn(table: "dbo.fim_cheques", name: "cheque_status", newName: "ChequeStatus");
            RenameColumn(table: "dbo.fim_cheques", name: "pay_date", newName: "PayDate");
            RenameColumn(table: "dbo.fim_cheques", name: "print_date", newName: "PrintDate");
            RenameColumn(table: "dbo.fim_cheques", name: "cheque_no", newName: "ChequeNo");
            RenameColumn(table: "dbo.fim_cheques", name: "cheque_book_seq", newName: "ChequeBookId");
            RenameColumn(table: "dbo.fim_cheques", name: "cheque_seq", newName: "ChequeId");
            RenameColumn(table: "dbo.fim_money_requests", name: "updated_when", newName: "UpdatedWhen");
            RenameColumn(table: "dbo.fim_money_requests", name: "updated_by", newName: "UpdatedBy");
            RenameColumn(table: "dbo.fim_money_requests", name: "created_when", newName: "CreatedWhen");
            RenameColumn(table: "dbo.fim_money_requests", name: "created_by", newName: "CreatedBy");
            RenameColumn(table: "dbo.fim_money_requests", name: "record_status", newName: "RecordStatus");
            RenameColumn(table: "dbo.fim_money_requests", name: "tran_grp_seq", newName: "TranGrpId");
            RenameColumn(table: "dbo.fim_money_requests", name: "debtor_contact_seq", newName: "DebtorContactId");
            RenameColumn(table: "dbo.fim_money_requests", name: "debtor_emp_seq", newName: "DebtorEmpId");
            RenameColumn(table: "dbo.fim_money_requests", name: "credit_card_no", newName: "CreditCardNo");
            RenameColumn(table: "dbo.fim_money_requests", name: "borrow_return_date", newName: "BorrowReturnDate");
            RenameColumn(table: "dbo.fim_money_requests", name: "borrow_end_date", newName: "BorrowEndDate");
            RenameColumn(table: "dbo.fim_money_requests", name: "borrow_start_date", newName: "BorrowStartDate");
            RenameColumn(table: "dbo.fim_money_requests", name: "borrow_type_seq", newName: "BorrowTypeId");
            RenameColumn(table: "dbo.fim_money_requests", name: "borrow_no", newName: "BorrowNo");
            RenameColumn(table: "dbo.fim_money_requests", name: "icm_dn_seq", newName: "DnId");
            RenameColumn(table: "dbo.fim_money_requests", name: "contact_seq", newName: "ContactId");
            RenameColumn(table: "dbo.fim_money_requests", name: "job_site_seq", newName: "JobSiteId");
            RenameColumn(table: "dbo.fim_money_requests", name: "emp_seq", newName: "EmpId");
            RenameColumn(table: "dbo.fim_money_requests", name: "bgm_proj_oper_seq", newName: "ProjOperId");
            RenameColumn(table: "dbo.fim_money_requests", name: "money_req_name", newName: "Name");
            RenameColumn(table: "dbo.fim_money_requests", name: "doc_ref_no", newName: "DoccumentNo");
            RenameColumn(table: "dbo.fim_money_requests", name: "ref_no", newName: "Code");
            RenameColumn(table: "dbo.fim_money_requests", name: "advance_bgm_source_seq", newName: "AdvanceBgSourceId");
            RenameColumn(table: "dbo.fim_money_requests", name: "use_advance", newName: "UseAdvance");
            RenameColumn(table: "dbo.fim_money_requests", name: "money_req_date", newName: "PayReqDate");
            RenameColumn(table: "dbo.fim_money_requests", name: "event_seq", newName: "PayEventId");
            RenameColumn(table: "dbo.fim_money_requests", name: "bgm_exp_grp_seq", newName: "ExpGrpId");
            RenameColumn(table: "dbo.fim_money_requests", name: "work_area_seq", newName: "WorkAreaId");
            RenameColumn(table: "dbo.fim_money_requests", name: "bgm_year", newName: "BgYear");
            RenameColumn(table: "dbo.fim_money_requests", name: "bgm_source_seq", newName: "BgSourceId");
            RenameColumn(table: "dbo.fim_money_requests", name: "money_req_seq", newName: "PayReqId");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "updated_when", newName: "UpdatedWhen");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "updated_by", newName: "UpdatedBy");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "created_when", newName: "CreatedWhen");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "created_by", newName: "CreatedBy");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "record_status", newName: "RecordStatus");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "bath_amount", newName: "NetAmount");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "amount_tax", newName: "AmountTax");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "amount_vat", newName: "AmountVat");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "percent_tax", newName: "PercentTax");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "percent_vat", newName: "PercentVat");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "job_site_seq", newName: "JobSiteId");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "bgm_proj_oper_exp_seq", newName: "ProjOperExpId");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "money_req_dtls_name", newName: "Name");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "money_req_seq", newName: "PayReqId");
            RenameColumn(table: "dbo.fim_money_request_dtls", name: "money_req_dtls_seq", newName: "PayReqDtlId");
            CreateIndex("dbo.FimPay", "PayMethodId");
            CreateIndex("dbo.FimPay", "PayEventId");
            AddForeignKey("dbo.FimPay", "PayMethodId", "dbo.FimMasLookUp", "LookUpId");
            AddForeignKey("dbo.FimPay", "PayEventId", "dbo.FimMasLookUp", "LookUpId", cascadeDelete: true);
            RenameTable(name: "dbo.fim_cheques", newName: "FimCheque");
            RenameTable(name: "dbo.fim_money_requests", newName: "FimPayRequest");
            RenameTable(name: "dbo.fim_money_request_dtls", newName: "FimPayRequestDtl");
        }
    }
}
